package com.woniuxy.oa;

import java.sql.Timestamp;
import java.util.List;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import com.woniuxy.oa.entity.Employee;
import com.woniuxy.oa.entity.Goods_purchase;
import com.woniuxy.oa.mapper.EmployeeMapper;
import com.woniuxy.oa.mapper.Goods_purchaseMapper;

@RunWith(SpringRunner.class)
@SpringBootTest
public class OaOfficeApplicationTestsPurchase {
	
	@Autowired
	Goods_purchaseMapper goods_purchaseMapper;
	@Autowired
	EmployeeMapper employeeMapper;
	@Test
	public void contextLoads() {
		Timestamp d = new Timestamp(System.currentTimeMillis());
		Goods_purchase goods_purchase=new Goods_purchase();
		goods_purchaseMapper.insertPurchaseGetGp_id(goods_purchase);
		System.out.println(goods_purchase.getGp_id());
	}
	
	//添加员工
	@Test
	public void testinsertEmployeeGetId() {
		Employee employee=new Employee();
		employee.setName("小李");
		employeeMapper.insertEmployeeGetId(employee);
		System.out.println(employee.getId());
	}
	
	@Test
	public void testupdatePurchaseByGp_id() {
		Timestamp d = new Timestamp(System.currentTimeMillis());
		Goods_purchase goods_purchase=new Goods_purchase();
		goods_purchase.setGp_id(4);
		goods_purchaseMapper.updatePurchaseByGp_id(goods_purchase);
	}
	
	@Test
	public void testdeletePurchaseByGp_id() {
		Integer gp_id=4;
		goods_purchaseMapper.deletePuchaseByGp_id(gp_id);
	}
	
	//根据gp_id查询申购信息和员工信息
	@Test
	public void testselectGoods_purchaseByGp_id() {
		Integer gp_id=4;
		Goods_purchase goods_purchase = goods_purchaseMapper.selectGoods_purchaseByGp_id(gp_id);
		System.out.println(goods_purchase);
	}
	
	//分页查询
	@Test
	public void testselectPage() {
		String name="王";
		List<Goods_purchase> goods_purchases = goods_purchaseMapper.selectGoods_purchaseConditionByName(name, 0, 10);
		Integer totalRecord = goods_purchaseMapper.selectGoods_purchaseTotalRecordById(name);
		System.out.println(goods_purchases);
		System.out.println(totalRecord);
	}
}
